<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/wipSummary.do?reporttype=inventorysummary" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext(); %>

<%
   String productId    = request.getParameter("product");
    
    if( productId == null || ( productId != null && productId.trim().length() == 0 ) )
    {
        productId = "0";
    }
%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></SCRIPT>
<SCRIPT language="JavaScript">

var dateElement = "";

function validatefields()
{
    formdoc = document.inventorySummaryReport;
 	errMsg = '';
	var pa	= document.getElementById("errors")

    if( chkDate( formdoc.asOfDate.value,'As of Date','N') == false )
	{
		pa.innerHTML = errMsg;
		formdoc.asOfDate.focus();
		return false;
	}
	pa.innerHTML = errMsg;

    return true;
}

function openCalendar( dateValue )
{
	dateElement = dateValue;
  	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
  	newWindow.moveTo(550,180);
  	newWindow.focus();
}

function assignDate( passedValue )
{
	dateElement.value=passedValue;
	window.focus();
}


function dateRange( fileType )
{
    var d = new Date();
    var day = d.getDate();
    var month = d.getMonth()+1;
    var year = d.getFullYear();
    var hour = d.getHours();
    var min = d.getMinutes();
    var sec = d.getSeconds();

    var reporttype = document.inventorySummaryReport.reporttype.value;

    var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;

    var success;
    success = true;
    success = validatefields();
    
    if( document.inventorySummaryReport.asOfDate.value != '' && success == true  )
    {
        var array = (document.inventorySummaryReport.asOfDate.value).split("/");
        if ( array[0] < 10 && array[0].length < 2)
            array[0] = "0"+array[0];
        if ( array[1] < 10 && array[1].length < 2 )
            array[1] = "0"+array[1];
        document.inventorySummaryReport.asOfDate.value = array[0]+"/"+array[1]+"/"+array[2];
    }
    

     if (document.inventorySummaryReport.product.value == '')
        document.inventorySummaryReport.prompt0.value='0';
     else
        document.inventorySummaryReport.prompt0.value = document.inventorySummaryReport.product.value;

     if (document.inventorySummaryReport.category.value == '')
        document.inventorySummaryReport.prompt1.value='0';
    else
        document.inventorySummaryReport.prompt1.value = document.inventorySummaryReport.category.value;

     if (document.inventorySummaryReport.vendorName.value == '')
        document.inventorySummaryReport.prompt2.value='0';
    else
        document.inventorySummaryReport.prompt2.value = document.inventorySummaryReport.vendorName.value;

    if (document.inventorySummaryReport.status.value == '')
        document.inventorySummaryReport.prompt3.value='0';
    else
        document.inventorySummaryReport.prompt3.value = document.inventorySummaryReport.status.value;

     if (document.inventorySummaryReport.asOfDate.value == '')
        document.inventorySummaryReport.prompt4.value='0';
    else
        document.inventorySummaryReport.prompt4.value = document.inventorySummaryReport.asOfDate.value;
        
        document.inventorySummaryReport.prompt5.value =defaultPrompt;
        document.inventorySummaryReport.prompt6.value =escape(document.inventorySummaryReport.psTypes.value);
        document.inventorySummaryReport.prompt7.value ='';
        document.inventorySummaryReport.prompt8.value ='';
        document.inventorySummaryReport.prompt9.value ='';
        document.inventorySummaryReport.prompt10.value='';

    if( success == true )
    {
        if( fileType == 2 )
        {
            var prompt0 = document.inventorySummaryReport.prompt0.value;
            var prompt1 = document.inventorySummaryReport.prompt1.value;
            var prompt2 = document.inventorySummaryReport.prompt2.value;
            var prompt3 = document.inventorySummaryReport.prompt3.value;
            var prompt4 = document.inventorySummaryReport.prompt4.value;
            var prompt5 = document.inventorySummaryReport.prompt5.value;
            var prompt6 = document.inventorySummaryReport.prompt6.value;
            var prompt7 = document.inventorySummaryReport.prompt7.value;
            var prompt8 = document.inventorySummaryReport.prompt8.value;
            var prompt9 = document.inventorySummaryReport.prompt9.value;
            var prompt10 = document.inventorySummaryReport.prompt10.value;

            var url = '<%=chipTracContext%>/operationsDataDumpReports.do?action=inventorySummaryReport&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8+ '&prompt9=' + prompt9+ '&prompt10=' + prompt10;
            newWindow = window.open ( url, 'InventorySummaryReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
        else
        {
            document.inventorySummaryReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Inventory_Summary_Report.rpt";
            document.inventorySummaryReport.submit();
            return true;
        }
    }
    else
    {
        return false;
    }
}

</script>
</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" >

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
    <TR>
        <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%@ include file="/jsp/operations/reports_side_menu.jsp" %>
            <!-- end of the side navigations -->
        </td>
        <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>

        <TD valign="top" width="100%">
            <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
            <BR>
            <!-- from here your body starts -->
            <form name="inventorySummaryReport" method="post">
            <input type="hidden" name="prompt0">
            <input type="hidden" name="prompt1">
            <input type="hidden" name="prompt2">
            <input type="hidden" name="prompt3">
            <input type="hidden" name="prompt4">
            <input type="hidden" name="prompt5">
            <input type="hidden" name="prompt6">
            <input type="hidden" name="prompt7">
            <input type="hidden" name="prompt8">
            <input type="hidden" name="prompt9">
            <input type="hidden" name="prompt10">
            <input type="hidden" name="reporttype" value="<%request.getParameter("reporttype");%>">

            <TABLE width='90%' align=right cellpadding='3' cellspacing='2' border='0' bordercolor='black'>
                <tr>
                   <TD width="100%" colspan='5' class="NArialW" align="center"> Inventory Summary Report </TD>
				   
                </tr>

                <TR><TD colspan='5'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='5'></TD></TR>
                <TR><TD colspan='5' align="left" class='NArialL'>&nbsp;<FONT id="errors" color='FF0000'></font></td></tr>
                <TR><TD colspan='5' id="chiptracErrors"><chiptrack:errors styleClass="NArialL"/></TD></TR>
                <TR>
                    <TD width="15%" class=NArialL align="left">Base Product : </TD>
                    <TD width="15%" class=NArialL >
                        <select size="1" name="product" class="txfield">
                            <option value="0">All Base Products</option>
                            <logic:iterate id="baseProductList" name="baseProductList" >
                                <logic:notEqual name="baseProductList" value="null">
                                    <option value ="<bean:write name="baseProductList" property="value"/>" >
                                        <bean:write name="baseProductList" property="label"/>
                                    </option>
                                </logic:notEqual>
                            </logic:iterate>
                        </select>
                    </TD>
                    <TD width="5%" class=NArialL >&nbsp; </TD>
                    <TD width="10%"  valign="center" align="left" class="NArialL"> Vendor : </TD>
					<td width="20%"  valign="center" class="NArialL">
						<select name="vendorName" class="txfield" >
						<option value="0">All Vendors</option>
						<logic:iterate id="vendorList" name="vendorList" >
							<logic:notEqual name="vendorList" value="null">
								<option value ="<bean:write name="vendorList" property="value"/>" >
									<bean:write name="vendorList" property="label"/>
								</option>
							</logic:notEqual>
						</logic:iterate>
						</select>
                    </td>
                    </TR>
					  <TR><td colspan="5"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height="1"></TD></TR>
					<tr>
                        <td width="15%" valign="center" align="left" class="NArialL">Lot Category :</td>
                        <td width="15%" valign="center" class="NArialL">
                            <select name="category" class="txfield" >
                            <logic:iterate id="categoryList" name="categoryList" >
                                <logic:notEqual name="categoryList" value="null">
                                    <option value ="<bean:write name="categoryList" property="value"/>" >
                                        <bean:write name="categoryList" property="label"/>
                                    </option>
                                </logic:notEqual>
                            </logic:iterate>
                         </select>
                        </td>
                        <TD width="5%" class=NArialL >&nbsp; </TD>
                        <TD width="10%"  valign="center" align="left" class="NArialL"> Status : </TD>
	                    <td width="20%" valign="center" class="NArialL">
                        <select name="status" class="txfield" >
                            <option value="0">All Status</option>
                            <logic:iterate id="statusList" name="statusList" >
                                <logic:notEqual name="statusList" value="null">
                                    <option value ="<bean:write name="statusList" property="value"/>" >
                                        <bean:write name="statusList" property="label"/>
                                    </option>
                                </logic:notEqual>
                            </logic:iterate>
                         </select>
                        </td>
                    </tr>
                
                    <input type="hidden" name="psTypes" value="<%= request.getAttribute("psTypes")%>">

                    <TR><td colspan="5"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=1></TD></TR>
                    <tr>
                        <td width="15%" valign="center" align="left" class="NArialL" >As of Date :</td>
                        <td width="15%" valign="center" class="NArialL">
                            <input type="text" name="asOfDate" size="12" class="txfield" maxlength="10">
                            <a href="javascript:openCalendar(document.inventorySummaryReport.asOfDate)">
                            <img onMouseOver="window.status='Click here to select date';return true" onMouseOut="window.status='';return true" border="0" align='center'
                            src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
                        </td>
                        <TD width="5%" class=NArialL align="right">&nbsp; </TD>
                        <td width="10%">&nbsp;</td>
                        <td width="20%"align="left" valign="top">
                            <a class="NArialL" href="javascript: dateRange(2)" onMouseOver="window.status='Click here to Export to Excel';return true" onMouseOut="window.status='';return true" title='Click here to Export to Excel' >Export to Excel</a>
                        </td>
                    </tr>
                    <TR><td colspan="5"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>&nbsp;</TD></TR>
                    <TR>
                        <TD colspan="5" width="100%" align="center">&nbsp;&nbsp;
                            <input type="image" onClick="javascript:return dateRange(1);"  border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Report';return true"onmouseout="window.status='';return true"title="Click here to Generate Report">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <a href="javascript:document.inventorySummaryReport.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"title="Click here to Reset"></a>
                        </TD>
                    </TR>
                </TABLE>
                <BR><BR><BR>
                </form>
            </TD>
            <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
        </TR>
    </TABLE>
    <!-- Footer starts here -->
    <%@ include file="/jsp/includes/footer.jsp" %>
    <!-- footer end here -->
    </BODY>
</HTML>

